﻿package plugin.shenlu.view
{
    import com.sh.game.util.*;
    import flash.events.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import uiresource.shenlu.*;
    import view.mornExtends.*;

    public class ShenluZBView extends ShenluZBViewUI
    {
        private var _Lv:int;
        private var save_index:int;

        public function ShenluZBView()
        {
            return;
        }// end function

        override protected function initializeView() : void
        {
            closeBtn.addEventListener(MouseEvent.CLICK, this.closeClick);
            return;
        }// end function

        override protected function createChildren() : void
        {
            loadUI("ShenluZBView.xml");
            return;
        }// end function

        public function showlist(param1:Array, param2:int) : void
        {
            var _loc_4:Object = null;
            var _loc_3:Array = [];
            this._Lv = param2;
            this.save_index = 0;
            for each (_loc_4 in param1)
            {
                
                if (this._Lv == _loc_4.lv)
                {
                    break;
                }
                if (this._Lv == 0)
                {
                    this.save_index = -1;
                    break;
                }
                var _loc_9:String = this;
                var _loc_10:* = this.save_index + 1;
                _loc_9.save_index = _loc_10;
            }
            if (param2 < 4)
            {
                this.save_index = 2;
            }
            var _loc_5:* = this.save_index + 3;
            if (this.save_index + 3 > param1.length)
            {
                _loc_5 = param1.length - 1;
            }
            var _loc_6:int = 0;
            while (_loc_6 <= _loc_5)
            {
                
                _loc_3.push(param1[_loc_6]);
                _loc_6++;
            }
            list.array = _loc_3;
            list.renderHandler = new Handler(this.listRender);
            return;
        }// end function

        private function listRender(param1:Component, param2:int) : void
        {
            var _loc_3:Object = null;
            var _loc_4:FlashItem = null;
            var _loc_5:Label = null;
            var _loc_6:Label = null;
            if (param2 < list.length)
            {
                _loc_3 = list.array[param2];
                _loc_4 = param1.getChildByName("item") as FlashItem;
                _loc_5 = param1.getChildByName("huodeLabel") as Label;
                _loc_6 = param1.getChildByName("nameLabel") as Label;
                _loc_4.data = _loc_3;
                if (this._Lv >= _loc_3.lv)
                {
                    _loc_5.text = "已获得";
                    _loc_6.text = _loc_3.name;
                    _loc_5.color = MColor.New62;
                }
                else
                {
                    _loc_6.text = _loc_3.name;
                    _loc_5.text = "未获得";
                    _loc_5.color = MColor.New56;
                }
            }
            return;
        }// end function

        protected function closeClick(event:MouseEvent) : void
        {
            this.visible = false;
            return;
        }// end function

    }
}
